﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace MySSOMVC
{
    /// <summary>
    /// Summary description for Config
    /// </summary>
    public class Config
    {
        public Config()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        /// <summary>
        /// Cookie timeout value in minutes in web.config
        /// </summary>
        public static int AUTH_COOKIE_TIMEOUT_IN_MINUTES
        {
            get
            {
                string StrCookieTimeout = ConfigurationManager.AppSettings[AppConstants.Configuration.AUTH_COOKIE_TIMEOUT_IN_MINUTES];
                int CookieTimeout = 30; //Default value
                if(int.TryParse(StrCookieTimeout, out CookieTimeout))
                {
                    return CookieTimeout;
                }
                else
                {
                    return 30;
                }
                
            }
        }

        /// <summary>
        /// Sliding expiration
        /// </summary>
        public static bool SLIDING_EXPIRATION
        {
            get
            {
                string StrSlidingExpiration = ConfigurationManager.AppSettings[AppConstants.Configuration.SLIDING_EXPIRATION];
                bool SlidingExpiration = true; //Default value
                bool.TryParse(StrSlidingExpiration, out SlidingExpiration);

                return SlidingExpiration;
            }
        }
    }
}